/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('paidms', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model AddStreamGroupHeaders {
  commonHeaders?: map[string]string,
  transToAlink?: string(name='TransToAlink'),
}

model AddStreamGroupRequest {
  algoTypeEnum?: string(name='AlgoTypeEnum'),
  alinkJobUser?: string(name='AlinkJobUser'),
  streamId?: long(name='StreamId'),
  streamTaskId?: int32(name='StreamTaskId'),
  taskId?: string(name='TaskId'),
  userNumber?: string(name='UserNumber'),
}

model AddStreamGroupResponseBody = {
  requestId?: string(name='RequestId'),
}

model AddStreamGroupResponse = {
  headers: map[string]string(name='headers'),
  body: AddStreamGroupResponseBody(name='body'),
}

async function addStreamGroup(request: AddStreamGroupRequest): AddStreamGroupResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers = new AddStreamGroupHeaders{};
  return addStreamGroupWithOptions(request, headers, runtime);
}

async function addStreamGroupWithOptions(request: AddStreamGroupRequest, headers: AddStreamGroupHeaders, runtime: Util.RuntimeOptions): AddStreamGroupResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.algoTypeEnum)) {
    body['AlgoTypeEnum'] = request.algoTypeEnum;
  }
  if (!Util.isUnset(request.alinkJobUser)) {
    body['AlinkJobUser'] = request.alinkJobUser;
  }
  if (!Util.isUnset(request.streamId)) {
    body['StreamId'] = request.streamId;
  }
  if (!Util.isUnset(request.streamTaskId)) {
    body['StreamTaskId'] = request.streamTaskId;
  }
  if (!Util.isUnset(request.taskId)) {
    body['TaskId'] = request.taskId;
  }
  if (!Util.isUnset(request.userNumber)) {
    body['UserNumber'] = request.userNumber;
  }

  var realHeaders : map[string]string = {};
  if (!Util.isUnset(headers.commonHeaders)) {
    realHeaders = headers.commonHeaders;
  }
  if (!Util.isUnset(headers.transToAlink)) {
    realHeaders['TransToAlink'] = Util.toJSONString(headers.transToAlink);
  }
  var req = new OpenApi.OpenApiRequest{ 
    headers = realHeaders,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'AddStreamGroup',
    version = '2021-01-06',
    protocol = 'HTTPS',
    pathname = `/pop/roa/api/v1.0/stream.json`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model ExportExperimentRequest {
  experimentId?: long(name='ExperimentId'),
}

model ExportExperimentResponseBody = {
  code?: string(name='Code'),
  data?: string(name='Data', description='实验内容'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model ExportExperimentResponse = {
  headers: map[string]string(name='headers'),
  body: ExportExperimentResponseBody(name='body'),
}

async function exportExperiment(request: ExportExperimentRequest): ExportExperimentResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return exportExperimentWithOptions(request, headers, runtime);
}

async function exportExperimentWithOptions(request: ExportExperimentRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ExportExperimentResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.experimentId)) {
    query['ExperimentId'] = request.experimentId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ExportExperiment',
    version = '2021-01-06',
    protocol = 'HTTPS',
    pathname = `/pop/roa/api/v1.0/migrate/exportExperiment.json`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model ExportExperimentTreeRequest {
  projectId?: long(name='ProjectId'),
}

model ExportExperimentTreeResponseBody = {
  code?: string(name='Code'),
  data?: map[string]any(name='Data', description='实验树'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model ExportExperimentTreeResponse = {
  headers: map[string]string(name='headers'),
  body: ExportExperimentTreeResponseBody(name='body'),
}

async function exportExperimentTree(request: ExportExperimentTreeRequest): ExportExperimentTreeResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return exportExperimentTreeWithOptions(request, headers, runtime);
}

async function exportExperimentTreeWithOptions(request: ExportExperimentTreeRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ExportExperimentTreeResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.projectId)) {
    query['ProjectId'] = request.projectId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ExportExperimentTree',
    version = '2021-01-06',
    protocol = 'HTTPS',
    pathname = `/pop/roa/api/v1.0/migrate/exportExperimentTree.json`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model ExportExperimentTreeByProjectOwnerRequest {
  projectId?: long(name='ProjectId'),
  treeOwnerId?: string(name='TreeOwnerId'),
}

model ExportExperimentTreeByProjectOwnerResponseBody = {
  code?: string(name='Code'),
  data?: map[string]any(name='Data', description='实验树'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model ExportExperimentTreeByProjectOwnerResponse = {
  headers: map[string]string(name='headers'),
  body: ExportExperimentTreeByProjectOwnerResponseBody(name='body'),
}

async function exportExperimentTreeByProjectOwner(request: ExportExperimentTreeByProjectOwnerRequest): ExportExperimentTreeByProjectOwnerResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return exportExperimentTreeByProjectOwnerWithOptions(request, headers, runtime);
}

async function exportExperimentTreeByProjectOwnerWithOptions(request: ExportExperimentTreeByProjectOwnerRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ExportExperimentTreeByProjectOwnerResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.projectId)) {
    query['ProjectId'] = request.projectId;
  }
  if (!Util.isUnset(request.treeOwnerId)) {
    query['TreeOwnerId'] = request.treeOwnerId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ExportExperimentTreeByProjectOwner',
    version = '2021-01-06',
    protocol = 'HTTPS',
    pathname = `/pop/roa/api/v1.0/migrate/exportExperimentTreeByProjectOwner.json`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model GetAlinkAlgoInfoRequest {
  algoName?: string(name='AlgoName'),
  userNumber?: string(name='UserNumber'),
}

model GetAlinkAlgoInfoResponseBody = {
  data?: {
    alinkUrl?: string(name='AlinkUrl'),
    needTrans?: boolean(name='NeedTrans'),
    publicKeyStr?: string(name='PublicKeyStr'),
  }(name='Data'),
  requestId?: string(name='RequestId'),
}

model GetAlinkAlgoInfoResponse = {
  headers: map[string]string(name='headers'),
  body: GetAlinkAlgoInfoResponseBody(name='body'),
}

async function getAlinkAlgoInfo(request: GetAlinkAlgoInfoRequest): GetAlinkAlgoInfoResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getAlinkAlgoInfoWithOptions(request, headers, runtime);
}

async function getAlinkAlgoInfoWithOptions(request: GetAlinkAlgoInfoRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetAlinkAlgoInfoResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.algoName)) {
    query['AlgoName'] = request.algoName;
  }
  if (!Util.isUnset(request.userNumber)) {
    query['UserNumber'] = request.userNumber;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetAlinkAlgoInfo',
    version = '2021-01-06',
    protocol = 'HTTPS',
    pathname = `/pop/roa/api/v1.0/getAlinkAlgoInfo.json`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model GetAlinkAlgoPublicKeyResponseBody = {
  data?: {
    alinkUrl?: string(name='AlinkUrl'),
    publicKeyStr?: string(name='PublicKeyStr'),
  }(name='Data'),
  requestId?: string(name='RequestId'),
}

model GetAlinkAlgoPublicKeyResponse = {
  headers: map[string]string(name='headers'),
  body: GetAlinkAlgoPublicKeyResponseBody(name='body'),
}

async function getAlinkAlgoPublicKey(): GetAlinkAlgoPublicKeyResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getAlinkAlgoPublicKeyWithOptions(headers, runtime);
}

async function getAlinkAlgoPublicKeyWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): GetAlinkAlgoPublicKeyResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'GetAlinkAlgoPublicKey',
    version = '2021-01-06',
    protocol = 'HTTPS',
    pathname = `/pop/roa/api/v1.0/getAlinkAlgoPublicKey.json`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model GetProjectInfoRequest {
  projectId?: long(name='ProjectId'),
}

model GetProjectInfoResponseBody = {
  code?: string(name='Code'),
  data?: map[string]any(name='Data', description='project info'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model GetProjectInfoResponse = {
  headers: map[string]string(name='headers'),
  body: GetProjectInfoResponseBody(name='body'),
}

async function getProjectInfo(request: GetProjectInfoRequest): GetProjectInfoResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getProjectInfoWithOptions(request, headers, runtime);
}

async function getProjectInfoWithOptions(request: GetProjectInfoRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetProjectInfoResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.projectId)) {
    query['ProjectId'] = request.projectId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetProjectInfo',
    version = '2021-01-06',
    protocol = 'HTTPS',
    pathname = `/pop/roa/api/v1.0/migrate/getProjectInfo.json`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model ListUsedProjectsResponseBody = {
  code?: string(name='Code'),
  data?: [ 
    {
      projectDesc?: string(name='ProjectDesc'),
      projectId?: long(name='ProjectId'),
      projectIdentifier?: string(name='ProjectIdentifier'),
      projectName?: string(name='ProjectName'),
      tenantId?: long(name='TenantId'),
    }
  ](name='Data', description='project列表'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model ListUsedProjectsResponse = {
  headers: map[string]string(name='headers'),
  body: ListUsedProjectsResponseBody(name='body'),
}

async function listUsedProjects(): ListUsedProjectsResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listUsedProjectsWithOptions(headers, runtime);
}

async function listUsedProjectsWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): ListUsedProjectsResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'ListUsedProjects',
    version = '2021-01-06',
    protocol = 'HTTPS',
    pathname = `/pop/roa/api/v1.0/migrate/listUsedProjects.json`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model ListUsedProjectsByOwnerResponseBody = {
  code?: string(name='Code'),
  data?: [ 
    {
      projectDesc?: string(name='ProjectDesc'),
      projectId?: long(name='ProjectId'),
      projectIdentifier?: string(name='ProjectIdentifier'),
      projectName?: string(name='ProjectName'),
      tenantId?: long(name='TenantId'),
    }
  ](name='Data', description='project列表'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model ListUsedProjectsByOwnerResponse = {
  headers: map[string]string(name='headers'),
  body: ListUsedProjectsByOwnerResponseBody(name='body'),
}

async function listUsedProjectsByOwner(): ListUsedProjectsByOwnerResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listUsedProjectsByOwnerWithOptions(headers, runtime);
}

async function listUsedProjectsByOwnerWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): ListUsedProjectsByOwnerResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'ListUsedProjectsByOwner',
    version = '2021-01-06',
    protocol = 'HTTPS',
    pathname = `/pop/roa/api/v1.0/migrate/listUsedProjectsByOwner.json`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model SaveAutomlJobIdRequest {
  instanceId?: long(name='InstanceId'),
  jobId?: long(name='JobId'),
  taskId?: long(name='TaskId'),
}

model SaveAutomlJobIdResponseBody = {
  code?: string(name='Code'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model SaveAutomlJobIdResponse = {
  headers: map[string]string(name='headers'),
  body: SaveAutomlJobIdResponseBody(name='body'),
}

async function saveAutomlJobId(request: SaveAutomlJobIdRequest): SaveAutomlJobIdResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return saveAutomlJobIdWithOptions(request, headers, runtime);
}

async function saveAutomlJobIdWithOptions(request: SaveAutomlJobIdRequest, headers: map[string]string, runtime: Util.RuntimeOptions): SaveAutomlJobIdResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.jobId)) {
    query['JobId'] = request.jobId;
  }
  if (!Util.isUnset(request.taskId)) {
    query['TaskId'] = request.taskId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'SaveAutomlJobId',
    version = '2021-01-06',
    protocol = 'HTTPS',
    pathname = `/pop/roa/api/v1.0/automlJob.json`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model SaveAutomlModelRequest {
  auc?: string(name='Auc'),
  executionRecordId?: long(name='ExecutionRecordId'),
  experimentId?: long(name='ExperimentId'),
  f1score?: string(name='F1score'),
  id?: long(name='Id'),
  indicator?: string(name='Indicator'),
  indicatorData?: string(name='IndicatorData'),
  instanceId?: long(name='InstanceId'),
  isMigrate?: int32(name='IsMigrate'),
  iterations?: int32(name='Iterations'),
  modelIndex?: int32(name='ModelIndex'),
  modelName?: string(name='ModelName'),
  modelParam?: string(name='ModelParam'),
  precisionScore?: string(name='PrecisionScore'),
  recall?: string(name='Recall'),
  roc?: string(name='Roc'),
  status?: int32(name='Status'),
  taskId?: long(name='TaskId'),
}

model SaveAutomlModelResponseBody = {
  code?: string(name='Code'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model SaveAutomlModelResponse = {
  headers: map[string]string(name='headers'),
  body: SaveAutomlModelResponseBody(name='body'),
}

async function saveAutomlModel(request: SaveAutomlModelRequest): SaveAutomlModelResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return saveAutomlModelWithOptions(request, headers, runtime);
}

async function saveAutomlModelWithOptions(request: SaveAutomlModelRequest, headers: map[string]string, runtime: Util.RuntimeOptions): SaveAutomlModelResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.taskId)) {
    query['TaskId'] = request.taskId;
  }

  var body : map[string]any= {};
  if (!Util.isUnset(request.auc)) {
    body['Auc'] = request.auc;
  }
  if (!Util.isUnset(request.executionRecordId)) {
    body['ExecutionRecordId'] = request.executionRecordId;
  }
  if (!Util.isUnset(request.experimentId)) {
    body['ExperimentId'] = request.experimentId;
  }
  if (!Util.isUnset(request.f1score)) {
    body['F1score'] = request.f1score;
  }
  if (!Util.isUnset(request.id)) {
    body['Id'] = request.id;
  }
  if (!Util.isUnset(request.indicator)) {
    body['Indicator'] = request.indicator;
  }
  if (!Util.isUnset(request.indicatorData)) {
    body['IndicatorData'] = request.indicatorData;
  }
  if (!Util.isUnset(request.isMigrate)) {
    body['IsMigrate'] = request.isMigrate;
  }
  if (!Util.isUnset(request.iterations)) {
    body['Iterations'] = request.iterations;
  }
  if (!Util.isUnset(request.modelIndex)) {
    body['ModelIndex'] = request.modelIndex;
  }
  if (!Util.isUnset(request.modelName)) {
    body['ModelName'] = request.modelName;
  }
  if (!Util.isUnset(request.modelParam)) {
    body['ModelParam'] = request.modelParam;
  }
  if (!Util.isUnset(request.precisionScore)) {
    body['PrecisionScore'] = request.precisionScore;
  }
  if (!Util.isUnset(request.recall)) {
    body['Recall'] = request.recall;
  }
  if (!Util.isUnset(request.roc)) {
    body['Roc'] = request.roc;
  }
  if (!Util.isUnset(request.status)) {
    body['Status'] = request.status;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'SaveAutomlModel',
    version = '2021-01-06',
    protocol = 'HTTPS',
    pathname = `/pop/roa/api/v1.0/automl.json`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

model SaveOdpsInstanceRequest {
  gmtCreate?: string(name='GmtCreate'),
  nodeInstanceId?: long(name='NodeInstanceId'),
  odpsInstanceId?: string(name='OdpsInstanceId'),
  odpsInstanceStatus?: int32(name='OdpsInstanceStatus'),
  taskId?: string(name='TaskId'),
}

model SaveOdpsInstanceResponseBody = {
  requestId?: string(name='RequestId'),
}

model SaveOdpsInstanceResponse = {
  headers: map[string]string(name='headers'),
  body: SaveOdpsInstanceResponseBody(name='body'),
}

async function saveOdpsInstance(request: SaveOdpsInstanceRequest): SaveOdpsInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return saveOdpsInstanceWithOptions(request, headers, runtime);
}

async function saveOdpsInstanceWithOptions(request: SaveOdpsInstanceRequest, headers: map[string]string, runtime: Util.RuntimeOptions): SaveOdpsInstanceResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.gmtCreate)) {
    body['GmtCreate'] = request.gmtCreate;
  }
  if (!Util.isUnset(request.nodeInstanceId)) {
    body['NodeInstanceId'] = request.nodeInstanceId;
  }
  if (!Util.isUnset(request.odpsInstanceId)) {
    body['OdpsInstanceId'] = request.odpsInstanceId;
  }
  if (!Util.isUnset(request.odpsInstanceStatus)) {
    body['OdpsInstanceStatus'] = request.odpsInstanceStatus;
  }
  if (!Util.isUnset(request.taskId)) {
    body['TaskId'] = request.taskId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'SaveOdpsInstance',
    version = '2021-01-06',
    protocol = 'HTTPS',
    pathname = `/pop/roa/api/v1.0/instance.json`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

